package logic

import (
	"context"
	"user-management/model/mysql"

	"user-management/userrpc/internal/svc"
	"user-management/userrpc/userrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShowUpdateLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShowUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowUpdateLogic {
	return &ShowUpdateLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ShowUpdateLogic) ShowUpdate(in *userrpc.ShowRequest) (*userrpc.ShowResponse, error) {
	// todo: add your logic here and delete this line
	var user mysql.User
	mysql.DB.Debug().Where("id=?", in.Id).Find(&user)
	return &userrpc.ShowResponse{
		Account:  user.Account,
		Password: user.Password,
	}, nil
}
